package priv.pront.code.lanqiao.competition.course.date0328;

import java.util.Scanner;

public class 第十届省赛C组_旋转 {
    static int n, m;
    static int[][] matrix,target;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        m = scanner.nextInt();
        matrix = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                matrix[i][j] = scanner.nextInt();
            }
        }
        rotate();
        print();
    }

    private static void print() {
        for (int i = 0; i < target.length; i++) {
            for (int j = 0; j < target[0].length; j++) {
                System.out.print(target[i][j] + " ");
            }
            System.out.println();
        }
    }

    private static void rotate() {
        target = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                target[i][j] = matrix[n - j - 1][i];
            }
        }
    }
}
